package monster.com.cvh.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.github.chrisbanes.photoview.PhotoView;

import monster.com.cvh.R;

/**
 * @author: monster
 * @data: 2018/4/9
 * @function: 图片预览碎片界面
 */
public class PicLookFragment extends Fragment {
    private Bundle arg ;
    private PhotoView mPhotoView;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        arg = getArguments();

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_pic_look,null);
        mPhotoView = view.findViewById(R.id.iv_fragment_pic_look);
        int page=arg.getInt("pager_num");
        String urlPath1 = arg.getString("urlPath1");
//        String urlPath2 = arg.getString("urlPath2");
//        String urlPath3 = arg.getString("urlPath3");
        Glide.with(this)
                .load(urlPath1)
                .placeholder(R.mipmap.pic_loading)
                .error(R.mipmap.pic_loading_failed)
                .thumbnail(0.1f)
                .fitCenter()
                .crossFade()
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .into(mPhotoView);
        return view ;

    }


    public  static  PicLookFragment newInstance(Bundle args) {
        PicLookFragment fragment = new PicLookFragment();
        fragment.setArguments(args);
        return fragment;
    }
}
